package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysConfigDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysConfig;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysConfigDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    BasicColumn[] selectList = BasicColumn.columnList(configId, createTime, configName, configCode, configValue, valueStyle, isMust, memo);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysConfig> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysConfig> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysConfigResult")
    Optional<TSysConfig> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysConfigResult", value = {
        @Result(column="config_id", property="configId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="config_name", property="configName", jdbcType=JdbcType.VARCHAR),
        @Result(column="config_code", property="configCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="config_value", property="configValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="value_style", property="valueStyle", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_must", property="isMust", jdbcType=JdbcType.BIT),
        @Result(column="memo", property="memo", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysConfig> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int deleteByPrimaryKey(String configId_) {
        return delete(c -> 
            c.where(configId, isEqualTo(configId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int insert(TSysConfig record) {
        return MyBatis3Utils.insert(this::insert, record, TSysConfig, c ->
            c.map(configId).toProperty("configId")
            .map(createTime).toProperty("createTime")
            .map(configName).toProperty("configName")
            .map(configCode).toProperty("configCode")
            .map(configValue).toProperty("configValue")
            .map(valueStyle).toProperty("valueStyle")
            .map(isMust).toProperty("isMust")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int insertMultiple(Collection<TSysConfig> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysConfig, c ->
            c.map(configId).toProperty("configId")
            .map(createTime).toProperty("createTime")
            .map(configName).toProperty("configName")
            .map(configCode).toProperty("configCode")
            .map(configValue).toProperty("configValue")
            .map(valueStyle).toProperty("valueStyle")
            .map(isMust).toProperty("isMust")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int insertSelective(TSysConfig record) {
        return MyBatis3Utils.insert(this::insert, record, TSysConfig, c ->
            c.map(configId).toPropertyWhenPresent("configId", record::getConfigId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(configName).toPropertyWhenPresent("configName", record::getConfigName)
            .map(configCode).toPropertyWhenPresent("configCode", record::getConfigCode)
            .map(configValue).toPropertyWhenPresent("configValue", record::getConfigValue)
            .map(valueStyle).toPropertyWhenPresent("valueStyle", record::getValueStyle)
            .map(isMust).toPropertyWhenPresent("isMust", record::getIsMust)
            .map(memo).toPropertyWhenPresent("memo", record::getMemo)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default Optional<TSysConfig> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default List<TSysConfig> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default List<TSysConfig> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default Optional<TSysConfig> selectByPrimaryKey(String configId_) {
        return selectOne(c ->
            c.where(configId, isEqualTo(configId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysConfig, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysConfig record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(configId).equalTo(record::getConfigId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(configName).equalTo(record::getConfigName)
                .set(configCode).equalTo(record::getConfigCode)
                .set(configValue).equalTo(record::getConfigValue)
                .set(valueStyle).equalTo(record::getValueStyle)
                .set(isMust).equalTo(record::getIsMust)
                .set(memo).equalTo(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysConfig record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(configId).equalToWhenPresent(record::getConfigId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(configName).equalToWhenPresent(record::getConfigName)
                .set(configCode).equalToWhenPresent(record::getConfigCode)
                .set(configValue).equalToWhenPresent(record::getConfigValue)
                .set(valueStyle).equalToWhenPresent(record::getValueStyle)
                .set(isMust).equalToWhenPresent(record::getIsMust)
                .set(memo).equalToWhenPresent(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int updateByPrimaryKey(TSysConfig record) {
        return update(c ->
            c.set(createTime).equalTo(record::getCreateTime)
            .set(configName).equalTo(record::getConfigName)
            .set(configCode).equalTo(record::getConfigCode)
            .set(configValue).equalTo(record::getConfigValue)
            .set(valueStyle).equalTo(record::getValueStyle)
            .set(isMust).equalTo(record::getIsMust)
            .set(memo).equalTo(record::getMemo)
            .where(configId, isEqualTo(record::getConfigId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_config")
    default int updateByPrimaryKeySelective(TSysConfig record) {
        return update(c ->
            c.set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(configName).equalToWhenPresent(record::getConfigName)
            .set(configCode).equalToWhenPresent(record::getConfigCode)
            .set(configValue).equalToWhenPresent(record::getConfigValue)
            .set(valueStyle).equalToWhenPresent(record::getValueStyle)
            .set(isMust).equalToWhenPresent(record::getIsMust)
            .set(memo).equalToWhenPresent(record::getMemo)
            .where(configId, isEqualTo(record::getConfigId))
        );
    }
}